package com.tianyu.common;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.text.SimpleDateFormat;
import java.util.concurrent.*;

/**********************************
 * @Author YSW
 * @Description
 * @Date 2024/4/12 - 14:30
 **********************************/


@Data
@Slf4j
@Configuration
@ConfigurationProperties(prefix = "app-constants")
public class AppConstants {

    public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

    private ThreadPoolConfig threadPoolConfig;

    private boolean third01ValidRequest;


    @Data
    public static final class ThreadPoolConfig {

        private int corePoolSize;

        private int maximumPoolSize;

        private long keepAliveTime;

        private int capacity;
    }

    @Bean
    public Executor threadPool() {
        return new ThreadPoolExecutor(threadPoolConfig.getCorePoolSize(),
                threadPoolConfig.getMaximumPoolSize(), threadPoolConfig.getKeepAliveTime(),
                TimeUnit.SECONDS, new LinkedBlockingQueue<>(threadPoolConfig.getCapacity()),
                Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardOldestPolicy());
    }






    public TianyuServer tianyuServer;

    @Data
    public static final class TianyuServer {

        public String httpPrefix;

        public String tcpHost;

        public Integer tcpPort;

        public HttpPath httpPathPrefix;
    }

    @Data
    public static final class HttpPath {

        public String login;

        public String boxListGet;

        public String boxUpdatePost;

        public String boxHistoryPost;

        public String boxLiveUpdatePost;

        public String boxLiveOpenGetPrefix;

        public String boxLivePullGetPrefix;

        public String boxPhotosPost;

        public String kmzConvertPost;

        public String hangarListGet;

        public String hangarControlGetPrefix;

        public String hangarLinePost;

        public String hangarUpdatePost;

        public String hangarOutVideoGetPrefix;

        public String hangarInVideoGetPrefix;

        public String hangarUavTakeoffPost;

        public String lineTemplateExecutePost;

        public String lastLineGetPrefix;

        public String lineControlGetPrefix;

    }
}
